package com.example.chat.controller;

import com.example.common.common.config.response.Response;
import jakarta.websocket.server.PathParam;
import lombok.RequiredArgsConstructor;
import com.example.chat.model.ChatHistoryVO;
import com.example.chat.model.ChatModel;
import com.example.chat.model.ChatSessionMessageVO;
import org.springframework.web.bind.annotation.*;
import com.example.chat.service.ChatService;

import java.util.List;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/6/30 21:26
 **/
@RestController
@RequestMapping("/api/chat")
@RequiredArgsConstructor
public class ChatController {

    private final ChatService chatService;

    @GetMapping()
    public List<ChatHistoryVO> getChatHistory(@PathParam("type") String type) {
        return chatService.getChatHistory(type);
    }

    @GetMapping("/{chatId}")
    public ChatSessionMessageVO getChatConversationMessage(@PathVariable String chatId) {
        return chatService.getChatSessionMessage(chatId);
    }

    @PostMapping("/completions")
    public Response<String> chat(@RequestBody ChatModel chatModel) {
        return Response.success(chatService.addChatRecord(chatModel));
    }

//    @PostMapping(value = "/chat-flux", produces = "text/html;charset=utf-8")
//    public Flux<String> chatFlux(@RequestBody ChatModel chatModel) {
//        return chatClient.prompt()
//                .user(chatModel.getContent())
//                .stream()
//                .content();
//    }

}
